package fr.coding.kata.nantes.bench;

import java.util.concurrent.Callable;

/**
 * This class stores the information of a single run of a benchmark (one implementation for one
 * input data).
 *
 * @param <E> The type of the implementation.
 * @param <R> The type of the result.
 * @author Sylvain Leduby
 * @since 1.0
 */
class Run<E extends Callable<R>, R> {

    /**
     * The game that has been run.
     */
    private final E target;

    /**
     * The result of the run.
     */
    private R result;

    /**
     * The duration of the run.
     */
    private Long duration;

    public Run(final E target) {
        super();
        this.target = target;
    }

    public Run(final E target, final R result, final long duration) {
        this(target);
        this.result = result;
        this.duration = duration;
    }

    public R getResult() {
        return result;
    }

    public void setResult(final R result) {
        this.result = result;
    }

    public Long getDuration() {
        return duration;
    }

    public void setDuration(final Long duration) {
        this.duration = duration;
    }

    public E getTarget() {
        return target;
    }

    /**
     * Useful method to get the name of the implementation.
     *
     * @return The simple name of the class of the implementation that has been run.
     */
    public String getName() {
        return target.getClass().getName();
    }

}
